package mc0254;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Comparator;
import java.util.PriorityQueue;


public class Main {
	//输入优化模板开始
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StreamTokenizer st = new StreamTokenizer(br);
	static int rd() throws IOException {
		st.nextToken();
		return (int) st.nval;
	}
	//输入优化模板结束
	static int n, k, l, r;
	static long[] preSum;
	static int[][] f;
	//ST表创建模板
	public static void createST() {
		for (int i = 1; i <= n; i++) {
			f[i][0] = i;
		}
		int logN = (int) (Math.log(n) / Math.log(2));
		for (int i = 1; i <= logN; i++) {
			for (int j = 1; j + (1 << i) - 1 <= n; j++) {
				int x = f[j][i - 1];
				int y = f[j + (1 << (i - 1))][i - 1];
				f[j][i] = preSum[x] > preSum[y] ? x : y;
			}
		}
	}
	//ST表查询模板
	public static int qureyST(int l, int r) {
		int k = (int) (Math.log(r - l + 1) / Math.log(2));
		int x = f[l][k];
		int y = f[r - (1 << k) + 1][k];
		return preSum[x] > preSum[y] ? x : y;
	}
	//Node节点，内部静态类
	static class Node{
		int start,l,r,maxIndex;

		public Node(int start, int l, int r) {
		    // TODO Auto-generated constructor stub
		    this.start = start;
		    this.l = l;
		    this.r = r;
		    this.maxIndex = qureyST(l, r);
		}
		long get() {
		    return preSum[maxIndex] - preSum[start-1];
		}
	}
	public static void main(String[] args) throws IOException {
		n = rd();
		k = rd();
		l = rd();
		r = rd();
		preSum = new long[n + 1];
		f = new int[n + 1][(int) (Math.log(n) / Math.log(2)) + 1];

		for (int i = 1; i <= n; i++) {
			preSum[i] = rd();
			preSum[i] += preSum[i - 1];
		}
		createST();
		
		//创建优先队列，自定义排序规则
		PriorityQueue<Node> queue = new PriorityQueue<>(new Comparator<Node>() {
			@Override
			public int compare(Node o1, Node o2) {
				if (o1.get() - o2.get() >= 0) {//比较数值
                    return -1;  //o1大时，返回负数表示o1往前排，降序
                } else {
                    return 1;
                }
			}
		});

		//解题逻辑
		for (int i = 1; i <= n; i++) {
			if (i + l - 1 <= n) {
				queue.offer(new Node(i, i + l - 1, Math.min(n, i + r - 1)));
			}
		}
		long ans = 0;
		for (int i = 0; i < k; i++) {
			Node it = queue.poll();
			ans += it.get();

			if (it.maxIndex > it.l) {
				queue.offer(new Node(it.start, it.l, it.maxIndex - 1));
			}

			if (it.maxIndex < it.r) {
				queue.offer(new Node(it.start, it.maxIndex + 1, it.r));
			}
		}
		System.out.println(ans);
	}
}
